import pyautogui
import os


# 找图片
def find_img(image_path, confidence=0.6):
    try:
        print("开始查找")
        # 检查图片是否存在
        if not os.path.exists(image_path):
            print(f"图片路径 {image_path} 不存在")
            return
        
        # 查找图片在屏幕上的位置
        image_location = pyautogui.locateOnScreen(image_path, confidence=confidence)
        if image_location is None:
            print(f"未找到图片 {image_path}")
            return False
        else:
            center_x = image_location[0] + image_location[2] // 2
            center_y = image_location[1] + image_location[3] // 2
            
            return (center_x, center_y)
        
    except Exception as e:
        print(f"错误：{e}")
        return False

def mouse_move(x,y,duration=0.5):
    pyautogui.moveTo(x, y, duration=duration)
    print("鼠标已移动到目标位置")
    return True

# 主
def main():
    print('开始对比')
    
    image_path = "D:\\work\\project_st\\st_metting_compere\\run\\dept_cloud_and_app.png"  # 替换为你的图片路径
    is_find = find_img(image_path, confidence=0.8)  # 可以尝试调整置信度
    
    
    
    mouse_move(is_find[0], is_find[1])
    
    exit()

    

if __name__ == "__main__":
    
    main()
    
    
    
    
    # 
    # image_path = "D:\\work\\project_st\\st_metting_compere\\run\\dept.png"  # 替换为你的图片路径
    # is_find = move_mouse_to_image(image_path, confidence=0.8)  # 可以尝试调整置信度
    
    # image_path = "D:\\work\\project_st\\st_metting_compere\\run\\dept_all.png"  # 替换为你的图片路径
    # is_find 
    
    # image_path = "D:\\work\\project_st\\st_metting_compere\\run\\yuangong.png"  # 替换为你的图片路径
    # is_find = move_mouse_to_image(image_path, confidence=0.8)  # 可以尝试调整置信度
    # if is_find is True:
    #     round_check()